package com.wh.wisdomsite.xbox.client.session;

import com.wh.wisdomsite.xbox.ba.entity.Role;
import com.wh.wisdomsite.xbox.us.entity.Company;
import com.wh.wisdomsite.xbox.us.entity.Employee;
import com.wh.wisdomsite.xbox.us.entity.User;

import java.io.Serializable;
import java.util.List;

/**
 * 配置端会话用户
 *
 * @version V1.0
 * @Package: com.wh.wisdomsite.xbox.server.session
 * @author: 丁奕
 * @date: 2018-11-05 09:31
 * @Copyright 公司版权所有
 * @Company 贵州万华科技有限公司Copyright (c) 2016
 **/
public class ConfigClientSessionUser extends BaseSessionUser implements Serializable {

    /**
     * 基础用户信息
     */
    private User user;

    /**
     * 用户直属公司信息
     */
    private Company directCompany;

    /**
     * 用户所属总公司信息
     */
     private Company headCompany;

    /**
     * 用户所属员工（员工实体）
     */
    private Employee employee;

    /***用户所有角色信息***/
    /**
     * 用户所拥有所有角色List
     */
    private List<Role> roleList;

    /**
     * 用户最终数据权限
     */
    private String dataScope;

    /**
     * 返回最终的查询用的CompCode
     * @return
     */
    public String getFinalCompCode(){
        if(this.employee != null && this.employee.getCompany() != null && this.employee.getCompany().getCompCode() != null
                && this.employee.getCompany().getCompCode() != ""){
            return this.employee.getCompany().getCompCode();
        }
        if(this.directCompany != null && this.directCompany.getCompCode() != null && this.directCompany.getCompCode() != ""){
            return this.directCompany.getCompCode();
        }
        return null;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Company getDirectCompany() {
        return directCompany;
    }

    public void setDirectCompany(Company directCompany) {
        this.directCompany = directCompany;
    }

    public Company getHeadCompany() {
        return headCompany;
    }

    public void setHeadCompany(Company headCompany) {
        this.headCompany = headCompany;
    }

    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }

    public List<Role> getRoleList() {
        return roleList;
    }

    public void setRoleList(List<Role> roleList) {
        this.roleList = roleList;
    }


    public String getDataScope() {
        return dataScope;
    }

    public void setDataScope(String dataScope) {
        this.dataScope = dataScope;
    }
}
